require "pp"
require "charReader"

class Node
  include Comparable

  attr_accessor :val, :priority, :left, :right

  def initialize val=nil, priority=nil, left=nil, right=nil
	@val, @priority, @left, @right = val, priority, left, right
  end

  def leaf?
	return @left == nil && @right == nil
  end

  def <=> other
	other.val <=> @val
  end

  def to_s
	"Value: #{val}, Priority: #{priority}"
  end
end

reader = CharacterReader.new "../test/test.txt"
occurences = reader.occurences
nodes = []

occurences.each do |info|
  nodes << Node.new(info[1], info[0])
  nodes.sort
end 

nodes.each do |node|
  pp node.to_s
end
